let showNode = function () {
    let nodeList = [],
        data = [];

    //清除节点
    function removeNode(pName) {
        for (let index = 0; index < pName.length; index++) { //对标签进行遍历
            if (getClass(pName[index])[0].childNodes.length > 0)
                for (let i = getClass(pName[index])[0].childNodes.length - 1; i >= 0; i--) {
                    if (parseInt(index) === 0 && parseInt(i) === 1) {
                        // console.log(getClass(pName[index])[0].childNodes[i]);
                        break;
                    }
                    getClass(pName[index])[0].removeChild(getClass(pName[index])[0].childNodes[i]);
                }
        }
    }

    //添加节点
    function addNode(data) {
        //<div class="cont-inner share">\n' +
        let div = document.createElement("div");
        div.className = "cont-inner share";
        div.innerHTML =
            '                    <div class="share-header">\n' +
            '                        <a class="logo">\n' +
            '                            <img src="' + data.header.logoUrl + '">\n' +
            '                        </a>\n' +
            '                        <a class="name">' + data.header.name + '</a>\n' +
            '                        <a class="icon"><i class="fa fa-angle-right"></i></a>\n' +
            '                        <a class="property">' + data.header.property + '</a>\n' +
            '                        <div class="share-content">\n' + data.header.shareContent +
            '                        </div>\n' +
            '                        <div class="share-header-bottom"></div>\n' +
            '                    </div>\n' +
            '                    <div class="share-photo-title">\n' +
            '                        <a class="photo-title">' + data.title + '</a>\n' +
            '                    </div>\n' +
            '                    <div class="share-photo">\n' +
            '                        <img src="' + data.sharePhotoUrl + '">\n' +
            '                    </div>\n' +
            '                    <div class="share-function">\n' +
            '                        <a class="add-Pointer"><i class="fa fa-heart-o"></i></a>\n' +
            '                        <a class="add-share"><i class="fa fa-share-alt"></i></a>\n' +
            '                        <a class="add-comment"><i class="fa fa-comments-o"></i></a>\n' +
            '                        <div class="share-header-bottom"></div>\n' +
            '                    </div>\n' +
            '                    <div class="share-bottom">\n' +
            '                        <a class="logo">\n' +
            '                            <img src="' + data.comment[0].photoUrl + '">\n' +
            '                        </a>\n' +
            '                        <a class="name">' + data.comment[0].username + '</a>\n' +
            '                        <a class="share-comment">' + data.comment[0].shareComment + '</a>\n' +
            '                    </div>\n';
        return div;
    }

    //添加图片
    function addPhoto(data, length) {
        removeNode(["one-cont cont", "two-cont cont", "three-cont cont"]);
        let one = getClass("one-cont cont")[0],
            two = getClass("two-cont cont")[0],
            three = getClass("three-cont cont")[0];
        if (length === 3) {
            two.style.display = "inline-block";
            three.style.display = "inline-block";
            for (let i = 0; i < data.length; i++) {
                let json = data[i];
                for (let index = 0; index < json.length; index++) {
                    let div = addNode(json[index]);
                    if (index % 3 === 0) {
                        one.appendChild(div)
                    }
                    if (index % 3 === 1) {
                        two.appendChild(div)
                    }
                    if (index % 3 === 2) {
                        three.appendChild(div)
                    }
                }
            }
        }
        if (length === 2) {
            two.style.display = "inline-block";
            three.style.display = "none";
            for (let i = 0; i < data.length; i++) {
                let json = data[i];
                for (let index = 0; index < json.length; index++) {
                    let div = addNode(json[index]);
                    if (index % 2 === 0) {
                        one.appendChild(div)
                    }
                    if (index % 2 === 1) {
                        two.appendChild(div)
                    }
                }
            }
        }
        else if (length === 1) {
            two.style.display = "none";
            three.style.display = "none";
            for (let i = 0; i < data.length; i++) {
                let json = data[i];
                for (let index = 0; index < json.length; index++) {
                    let div = addNode(json[index]);
                    one.appendChild(div);
                }
            }
        }
    }

    //适应屏幕
    function adoptScreen() {
        let width = document.getElementsByTagName('body')[0].clientWidth;
        // console.log(width);
        if (width > 1872) {
            addPhoto(data, 3)
        } else if (width > 1311) {
            addPhoto(data, 2)
        } else {
            addPhoto(data, 1)
        }
    }

    //添加数据
    function addData(json_data) {
        data.push(json_data);
    }

    //得到三个div中高度最小的div的高度
    function getMinHeight() {
        let list = getClass("right-inner")[0].children;
        let minHeight = 100000000;
        let tempHeight = 0;
        for (let index = 0; index < list.length; index++) {
            if (list[index].style.display !== "none") {
                if (document.getElementsByTagName("body")[0].clientHeight > list[index].lastChild.clientHeight) {
                    tempHeight = document.getElementsByTagName("body")[0].clientHeight;
                } else {
                    tempHeight = list[index].lastChild.clientHeight
                }
                if ((list[index].clientHeight - tempHeight ) < minHeight) {
                    minHeight = list[index].clientHeight - tempHeight;
                }
            }
        }
        return minHeight;
    }

    return {
        adoptScreen: adoptScreen,
        addData: addData,
        getMinHeight: getMinHeight
    }
};